/*
 * Copyright 2011-2011 Tiago da Fonseca Frazao  All rights reserved.
 */

package mz.co.research.shared.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @author Tiago da Fonseca Frazao
 */
@Entity
@Table(name = "ANSWER")
public class Answer extends UpdatableEntity {

	@NotNull
	@Size(max = 1000)
	@Column(name = "TEXT", length = 1000, nullable = false)
	private String text;

	@ManyToOne
	@JoinColumn(name = "FK_QUESTION_ID", nullable = false)
	private Question question;

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * @param text
	 *            the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @return the question
	 */
	public Question getQuestion() {
		return question;
	}

	/**
	 * @param question
	 *            the question to set
	 */
	public void setQuestion(Question question) {
		this.question = question;
	}

	@Override
	public String toString() {
		StringBuilder buffer = new StringBuilder("\nAnswer");

		buffer.append(super.toString());

		buffer.append("\ntext  :" + this.text);

		return buffer.toString();
	}
}
